package util;

public class XYZPosition implements Comparable<XYZPosition>{

	@Override
	public String toString() {
		return "(" + X + "," + Y + "," + Z + ")";
	}


	public double X,Y,Z;
	
	public XYZPosition(double x, double y, double z){
		setPosition(x,y,z);
	}

	public XYZPosition() {
		this(0,0,0);
	}

	public void setPosition(double x, double y, double z) {
		setX(x);
		setY(y);
		setZ(z);		
	}

	public void setX(double myX) {
		this.X = myX;
	}

	public double getX() {
		return X;
	}

	public void setY(double myY) {
		this.Y = myY;
	}

	public double getY() {
		return Y;
	}

	public void setZ(double myZ) {
		this.Z = myZ;
	}

	public double getZ() {
		return Z;
	}
	
	public double distance(XYZPosition o){
		return distance(o.getX(), o.getY(), o.getZ());
		
	}

	private double distance(double x, double y, double z) {
		return Math.sqrt(Math.pow((x-X),2)+Math.pow((y-Y),2)+Math.pow((z-Z),2));
	}


	@Override
	public int compareTo(XYZPosition o) {
		if (((Double)X).compareTo(o.X) == 0){
			if (((Double)Y).compareTo(o.Y) == 0){
				if (((Double)Z).compareTo(o.Z) == 0){
					return 0;
				}
			}
		}
		return 1;
	}
}
